package mapreduce.statistics;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

/**
 * A stand alone program to generate useful results
 */

public class Statistics {
	public static void main(String[] args) {
		try {
			File file = new File(args[0]);
			BufferedReader reader = new BufferedReader(new FileReader(file));

			String line;
			int numerator = 0;
			int denominator = 0;
			int count = 0;
			while (null != (line = reader.readLine())) {
				String[] split = line.split("\t");
				int num = Integer.parseInt(split[1]);
				numerator += num * num;
				denominator += num;
				++count;
			}

			System.out.println("Number of connected components:" + count);
			System.out.println("weighted average size of connected components:"
					+ numerator / (double) denominator);
			System.out.println("Sum of column two is : " + denominator);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
